import React,{useState,useReducer} from "react";
import styles from "./index.less";
import {Button, message, Switch } from "antd";
import ProTable, { ProColumns } from "@ant-design/pro-table";

import {TableListItem} from '@/services/produceManager/TableEx.d'
import {queryRows} from '@/services/produceManager/TableExService'
import { PlusOutlined } from '@ant-design/icons';
import { FooterToolbar } from "@ant-design/pro-layout";

const columns:ProColumns<TableListItem>[] = [
  // const columns= [
  {
    title: "Name",
    dataIndex: "name",
    key: "name"
  },
  {
    title: "Age",
    dataIndex: "age",
    key: "age",
    width: "12%"
  },
  {
    title: "Address",
    dataIndex: "address",
    width: "30%",
    key: "address"
  }
];

// const data = [
//   {
//     key: 1,
//     name: "John Brown sr.",
//     age: 60,
//     address: "New York No. 1 Lake Park",
//     children: [
//       {
//         key: 11,
//         name: "John Brown",
//         age: 42,
//         address: "New York No. 2 Lake Park"
//       },
//       {
//         key: 12,
//         name: "John Brown jr.",
//         age: 30,
//         address: "New York No. 3 Lake Park",
//         children: [
//           {
//             key: 121,
//             name: "Jimmy Brown",
//             age: 16,
//             address: "New York No. 3 Lake Park"
//           }
//         ]
//       },
//       {
//         key: 13,
//         name: "Jim Green sr.",
//         age: 72,
//         address: "London No. 1 Lake Park",
//         children: [
//           {
//             key: 131,
//             name: "Jim Green",
//             age: 42,
//             address: "London No. 2 Lake Park",
//             children: [
//               {
//                 key: 1311,
//                 name: "Jim Green jr.",
//                 age: 25,
//                 address: "London No. 3 Lake Park"
//               },
//               {
//                 key: 1312,
//                 name: "Jimmy Green sr.",
//                 age: 18,
//                 address: "London No. 4 Lake Park"
//               }
//             ]
//           }
//         ]
//       }
//     ]
//   },
//   {
//     key: 2,
//     name: "Joe Black",
//     age: 32,
//     address: "Sidney No. 1 Lake Park"
//   }
// ];


// const [selectedTestRowsState, setSelectedTestRows] = useState({});

// const [selectedTestRowsState, setSelectedTestRows] =React.useState<string>('abcdeee');



const selectedTestRowsState='aaaaaaaaaacccccccccccc';

// rowSelection objects indicates the need for row selection
const rowSelection = {
  // onChange: (selectedRowKeys, selectedRows) => {
  //   console.log(
  //     `selectedRowKeys: ${selectedRowKeys}`,
  //     "selectedRows: ",
  //     selectedRows
  //   );
  // },
  onSelect: (record, selected, selectedRows) => {
    // setSelectedTestRows(record);
    console.log(record);
    console.log('--------------------A--------------------')
    console.log(selected);
    console.log('------------------B----------------------')
    console.log(record, selected, selectedRows);
    console.log('------------------C----------------------')

  },
  // onSelectAll: (selected, selectedRows, changeRows) => {
  //   console.log(selected, selectedRows, changeRows);
  // }
};

// const [checkStrictly, setCheckStrictly] = React.useState(false);

export default () => (
  <div className={styles.container}>
    <div id="components-table-demo-expand-children">


      {/* <Table columns={columns} rowSelection={rowSelection} dataSource={data} /> */}
      <ProTable columns={columns} 
      rowSelection={{...rowSelection,checkStrictly:false}}
      //  dataSource={data} 
      request={(params, sorter, filter) => queryRows({ ...params, sorter, filter })}
      toolBarRender={()=>[
        <Button type='default'>
           <PlusOutlined /> 预估交期
        </Button>
      ]}
      />
      <FooterToolbar
          extra={
            <div>
              已选择 <a style={{ fontWeight: 600 }}>2332</a> 项&nbsp;&nbsp;
              
            </div>
          }
        >
          <Button onClick={()=>{
            message.info('aaaaaaaaaaaaaaaaaaaaaaaaaaaaa'+selectedTestRowsState);
            // setSelectedTestRows({});
          }}>
            下达
          </Button>
        </FooterToolbar>

    </div>
  </div>
);
